﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Hotel_Project.Bean
{
    internal class TimeGuestinfoFormAction
    {
        public void Fulsh(DataGridView d,List<SystemSettingsDomain> list)
        {
            DataTable dataTable = new DataTable();
            dataTable.Columns.Add("客人编号");
            dataTable.Columns.Add("客人姓名");
            dataTable.Columns.Add("客人性别");
            dataTable.Columns.Add("客人身份证");
            dataTable.Columns.Add("住址");
            dataTable.Columns.Add("联系电话");
            dataTable.Columns.Add("备注说明");
            dataTable.Columns.Add("房间号");
            dataTable.Columns.Add("入住时间");
            string dataTime = System.DateTime.Now.ToString("yyyy年MM月dd日-");
            string[] t = dataTime.Split('-');
            foreach (SystemSettingsDomain domain in list)
            {
                bool paper = false;
                string[] x = domain.g_datetime.Split('日');
                paper = t[0].ToString() == x[0]+"日";
                if (paper)
                {
                    dataTable.Rows.Add(domain.g_Id,domain.g_Name,domain.Sex
                        ,domain.Id_card,domain.Address,domain.Telephone,domain.Remark
                        , domain.room_number,domain.g_datetime);
                }
            }
            d.DataSource = dataTable;
        }
        public void Alter(DataGridView d, List<SystemSettingsDomain> list,string Id)
        {
            DataTable dataTable = new DataTable();
            dataTable.Columns.Add("客人编号");
            dataTable.Columns.Add("客人姓名");
            dataTable.Columns.Add("客人性别");
            dataTable.Columns.Add("客人身份证");
            dataTable.Columns.Add("住址");
            dataTable.Columns.Add("联系电话");
            dataTable.Columns.Add("备注说明");
            dataTable.Columns.Add("房间号");
            dataTable.Columns.Add("入住时间");
            string dataTime = System.DateTime.Now.ToString("yyyy年MM月dd日-");
            string[] t = dataTime.Split('-');
            foreach (SystemSettingsDomain domain in list)
            {
                bool paper = false;
                paper = t[0].ToString() == domain.g_datetime.ToString();
                if (paper)
                {
                    int indexer=domain.g_Name.IndexOf(Id);
                    if (indexer>=0)                    
                    {
                        dataTable.Rows.Add(domain.g_Id, domain.g_Name, domain.Sex
                       , domain.Id_card, domain.Address, domain.Telephone, domain.Remark
                       , domain.room_number, domain.g_datetime);
                    }
                }
            }
            d.DataSource = dataTable;
        }
    }
}
